'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {
	const collection = db.collection('account-list')
	const res = await collection.where({
		id: event.id
	}).get()
	if (res.data && res.data.length) {
		return {
			code: 10001,
			message: '已存在账号',
			data: res.data
		}
	}
	const registerRes = await collection.add(event)
	return {
		code: 10,
		message: '注册成功',
		data: {
			...registerRes,
			...event
		}
	}
};
